<template>
  <div id="main" ref="myDiv"></div>
</template>

<script>
import * as echarts from 'echarts/core'
// 引入柱状图图表，图表后缀都为 Chart
import { RadarChart } from 'echarts/charts'
// 引入提示框，标题，直角坐标系组件，组件后缀都为 Component
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  LegendComponent
} from 'echarts/components'
// 引入 Canvas 渲染器，注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
import { CanvasRenderer } from 'echarts/renderers'

// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  RadarChart,
  CanvasRenderer,
  LegendComponent
])

export default {
  name: 'Radar',
  mounted() {
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'))
    // 绘制图表
    myChart.setOption({
      title: {
        text: '员工考核分析图'
      },
      legend: {
        data: ['平均水平', '个人价值'],
        orient: 'vertical',
        right: 0
      },
      radar: {
        // shape: 'circle',
        indicator: [
          { name: '工作效率', max: 100 },
          { name: '考勤', max: 100 },
          { name: '积极性', max: 100 },
          { name: '帮助同事', max: 100 },
          { name: '自主学习', max: 100 },
          { name: '正确率', max: 100 }
        ],
        name: {
          textStyle: {
            color: '#fff',
            backgroundColor: '#999',
            borderRadius: 3,
            padding: [3, 5]
          }
        }
      },
      series: [
        {
          name: '平均 vs 个人',
          type: 'radar',
          data: [
            {
              value: [88, 95, 60, 55, 79, 70],
              name: '平均水平'
            },
            {
              value: [98, 98, 54, 75, 88, 100],
              name: '个人价值'
            }
          ]
        }
      ]
    })
  }
}
</script>

<style scoped>
#main {
  width: 600px;
  height: 400px;
}
</style>
